<template>
  <div class="ry-step-container">
    <div
      :class="{'ry-step-content':true,'ry-step-content-current':current===index,'ry-step-content-nextOne':current+1===index,'ry-step-content-finished':current>index}"
      v-for="(item,index) in steps" :key="item.title">
      <div class="ry-step-icon">
        <ry-icon
          :type="current>=index?(current===index?iconList[index].on:iconList[index].finished):iconList[index].off">
        </ry-icon>
      </div>
      <div class="ry-step-title">
        {{item.title}}
      </div>
    </div>
  </div>
</template>
<script>
export default {
  components: {},
  props: {
    current: {
      type: Number,
      default: 0
    },
    steps: Array
  },
  data () {
    return {
      iconList: [
        {
          on: 'icon-lv1',
          off: 'icon-hui1',
          finished: 'icon-a-1'
        }, {
          on: 'icon-lv2',
          off: 'icon-hui2',
          finished: 'icon-a-2'
        }, {
          on: 'icon-lv3',
          off: 'icon-hui3',
          finished: 'icon-a-3'
        }, {
          on: 'icon-lv4',
          off: 'icon-hui4',
          finished: 'icon-a-4'
        }
      ]
    }
  },
  mounted () { },
  methods: {}
}
</script>
<style lang="less">
.ry-step-container {
  display: flex;
  justify-content: space-around;
  .ry-step-content {
    position: relative;
    text-align: center;
    width: 100px;
    flex-grow: 1;
  }
  .ry-step-content:first-child::after {
    width: 50%;
    right: 0;
  }
  .ry-step-content:last-child::after {
    width: 50%;
    left: 0;
  }
  .ry-step-content::after {
    position: absolute;
    top: 24px;
    display: block;
    width: 100%;
    height: 3px;
    z-index: 0;
    background: #7c8495;
    content: '';
  }
  .ry-step-content.ry-step-content-current::after {
    background: linear-gradient(to right, #43b8bf, @primary-color, #589ba2);
  }
  .ry-step-content.ry-step-content-current:first-child::after {
    background: linear-gradient(to right, @primary-color, #589ba2);
  }
  .ry-step-content.ry-step-content-current:last-child::after {
    background: linear-gradient(to right, #43b8bf, @primary-color);
  }
  .ry-step-content.ry-step-content-nextOne::after {
    background: linear-gradient(to right, #589ba2, #7c8495, #7c8495);
  }
  .ry-step-content.ry-step-content-finished::after {
    background: linear-gradient(to right, #58c0d4, #43b8bf);
  }
  .ry-step-icon {
    position: relative;
    z-index: 1;
    font-size: 32px;
  }
  .ry-step-title {
    margin-top: 12px;
    font-size: 16px;
    color: #7c8495;
    font-weight: 400;
  }
  .ry-step-content-current {
    .ry-step-title {
      font-size: 18px;
      font-weight: bold;
      color: @primary-color;
    }
  }
  .ry-step-content-finished {
    .ry-step-title {
      color: #58c0d4;
    }
  }
}
</style>
